/*
 * @(#)OnlineUserListener.java	2010-06-05
 * @ yangzq
 * @ 2010-06-05
 * @Company < Jinher Technology Development Company LTD. >
 */
package com.forum.core.filter;

import java.util.Date;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.log4j.Logger;

import com.forum.core.util.SpringContextUtil;

/**
 * @Project <CL-Allocation tool>
 * @version <1.0>
 * @Author  <yangzq>
 * @Date    <2010-06-05>
 * @description 用户在线判断
 */
public class OnlineUserListener implements HttpSessionListener {
	private final static Logger logger = Logger.getLogger(OnlineUserListener.class);

	public void sessionCreated(HttpSessionEvent event) {

	}

	public void sessionDestroyed(HttpSessionEvent event) {
		HttpSession session = event.getSession();
		// 取得登录的用户名
		/*UserInfo loginUser = (UserInfo) session.getAttribute("loginUser");
		if (loginUser != null) {
			IUserService userManager = SpringContextUtil.getBean("userService");
			TblSysUser user = userManager.get(loginUser.getUserId());
			user.setUserIsOnline("0"); //设置用户登陆状态
			userManager.update(user);
			session.removeAttribute("loginUser");
			//当用户会话失效时清除个人在线寻呼
			ICacheService cacheService = SpringContextUtil.getBean("cacheService");
			cacheService.clearCache(user.getUserId());
			logger.debug("用户 " + loginUser.getUserName() + "在" + new Date().toLocaleString() + "退出系统！");
		}*/
	}
}
